package com.lanou3g.ssm.web;

import com.lanou3g.ssm.bean.Book;
import com.lanou3g.ssm.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/book")
public class BookController {

    @Autowired
    private BookService bookService;

    @RequestMapping("/list")
    public String queryBooks(Model model, @RequestParam(required = false) Book condition) {
        List<Book> books = bookService.queryBooks(condition);
        model.addAttribute("books", books);
        return "booklist";
    }

}
